/*
// Write log message directly into file
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>

FILE *fp ;
static int SESSION_TRACKER; //Keeps track of session

char* get_time()
{
    time_t t;
    char *buf;

    time(&t);
    buf = (char*)malloc(strlen(ctime(&t)) + 1);

    snprintf(buf,strlen(ctime(&t)), "%s ", ctime(&t));

    return buf;
}

void print_log(char* filename, int line, char *fmt,...)
{
    va_list list;
    char *p, *string_value;
    int integer_value;

    if(SESSION_TRACKER > 0)
        fp = fopen ("log.txt", "a+");
    else
        fp = fopen ("log.txt", "w");

    fprintf(fp, "%s ", get_time());
    va_start(list, fmt);

    for (p = fmt; *p; ++p)
    {
        if (*p != '%') //If simple string
        {
            fputc(*p, fp);
        }
        else
        {
            switch (*++p)
            {
                // string
                case 's':
                {
                    string_value = va_arg(list, char *);

                    fprintf(fp, "%s", string_value);
                    continue;
                }

                // integer
                case 'd':
                {
                    integer_value = va_arg(list, int);

                    fprintf(fp, "%d", integer_value);
                    continue;
                }

                default:
                    fputc(*p, fp);
            }
        }
    }
    va_end(list);
    fprintf(fp," [%s][line: %d] ", filename, line);
    fputc('\n', fp);
    SESSION_TRACKER++;
    fclose(fp);
}*/
